/*
 * G2OResolve.h
 *
 *  Created on: Sep 11, 2016
 *      Author: ubuntu
 */

#ifndef G2O_G2ORESOLVE_H_
#define G2O_G2ORESOLVE_H_

#include <iostream>
#include <vector>
#include <queue>
#include <pthread.h>
#include "G2OSummary.h"

using namespace std;

class DBPool;
class G2OStatus;

class G2OResolve {
public:
	G2OResolve();
	virtual ~G2OResolve();

	virtual void push(G2OSummary *pSummary);
	virtual void init();
	virtual void run();
	virtual void stop();
	virtual void getBuf(unsigned char *buf, size_t n);

protected:
	void writeDB(G2OSummary *);

private:
	void createAllDB(Connection *pConn);
	void saveStatus(G2OStatus *pStatus);
	int hash(const char *s);

private:
	queue<G2OSummary *> m_lstSummary;
	pthread_mutex_t m_summa_mutex;

	DBPool *m_pDBPool;

	bool m_bTerminated;

	StatusList m_arrStatus[HASH_SIZE];
};


#endif /* G2O_G2ORESOLVE_H_ */
